package com.jt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import com.jt.service.UserService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class UserServiceImpl implements UserService {
    private static Map<Integer,String> paramMap=new HashMap<>();
    static {
        paramMap.put(1,"username");
        paramMap.put(2, "phone");
        paramMap.put(3, "email");

    }
    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean checkUser(String param, Integer type) {
        String colum = paramMap.get(type);
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq(colum, param);
        Integer count = userMapper.selectCount(wrapper);
        return count>0;
    }

    @Override
    public List<User> selectUserList() {
        List<User> list = userMapper.selectList(null);
        return list;
    }
}
